package com.xuecheng.content.api;

import com.xuecheng.content.mapper.TeachplanMapper;
import com.xuecheng.content.model.dto.BindTeachplanMediaDto;
import com.xuecheng.content.model.dto.SaveTeachplanDto;
import com.xuecheng.content.model.dto.TeachplanDto;
import com.xuecheng.content.service.impl.TeachplanMediaServiceImpl;
import com.xuecheng.content.service.impl.TeachplanServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 冯佳鑫 又菜又爱学
 * @version 1.0
 * @DATE now()
 * 课程计划接口
 */
@Api(value = "课程计划接口" ,tags ="课程计划接口")
@RestController
public class TeachPlanController {
    /**
     * 查询课程计划
     */
    @Autowired
    TeachplanServiceImpl teachplanService;
    @ApiOperation("查询课程计划")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachplanDto> queryteachplan(@PathVariable Long courseId){
return teachplanService.selectTeachplan(courseId);
    }
    /**
     * 新增或者修改课程计划接口
     */

    @ApiOperation("新增或者修改课程计划接口")
    @PostMapping("/teachplan")
    public void saveteachplan(@RequestBody SaveTeachplanDto saveTeachplanDto) {
        teachplanService.saveteachplan(saveTeachplanDto);
    }
    /**
     * 删除课程计划接口
     */

    @ApiOperation("删除课程计划接口")
    @DeleteMapping("/teachplan/{id}")
    public void saveteachplan(@PathVariable Long id) {
        teachplanService.deleteteachplan(id);
    }

    @ApiOperation("课程计划上移接口")
    @PostMapping("/teachplan/moveup/{id}")
    public void moveUpTeachPlan(@PathVariable Long id) {
     teachplanService.moveupteachplan(id);
    }

    @ApiOperation("课程计划下移接口")
    @PostMapping("/teachplan/movedown/{id}")
    public void moveDownTeachPlan(@PathVariable Long id) {
        teachplanService.movedownteachplan(id);
    }

    @Autowired
    TeachplanMediaServiceImpl teachplanMediaService;
    @ApiOperation(value = "课程计划和媒资信息绑定")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto){
        teachplanMediaService.associationMedia(bindTeachplanMediaDto);
    }
}
